
const { MongoClient } = require('mongodb');


const URL = 'mongodb://blog:linshunli@81.68.131.25:27017/'
const DB_NAME = 'blog'


const client = new MongoClient(URL,{
    useUnifiedTopology:true
})

// 6.连接数据库
client.connect((err)=>{
    if(err){
        console.log(err)
        return
    }
    console.log('连接成功')
})


module.exports = {
    db:client.db(DB_NAME),
    close:()=>{client.close()}
}


